package web

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"testPaper/common"
	"testPaper/model"
	"testPaper/response"
)

// banner 图

func BannerImg(c *gin.Context) {
	DB := common.GetDB()
	name := c.PostForm("name")
	url := c.PostForm("url")
	imgUrl := c.PostForm("imgUrl")

	if imgUrl == "" {
		response.Reponse(c, http.StatusOK, 422, nil, "图片不能为空")
		return
	}
	banner := model.Banner{
		Name:   name,
		Url:    url,
		ImgUrl: imgUrl,
	}
	DB.Create(&banner)
	response.Reponse(c, http.StatusOK, 200, nil, "上传成功")
	return
}
